<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <%- include('../../_global/baseLibs') %>
    <link href="/static/lib/swiper/swiper.min.css" rel="stylesheet" />
    <link href="/static/css/publicqyfw.css" rel="stylesheet" />
    <link href="/static/css/pageqyfw.css" rel="stylesheet" />
    <title>在线签约</title>
    <titleType style="display: none">signOnline</titleType>
</head>
<body>
<section class="page-wrap consult-zx">
    <div class="consult-list-box">
        <ul>
            <li>
                <a id="hosList">
                    <img src="/static/images/qyfw/address.png">
                    <span class="red-cir">全部医院<i></i></span>
                    <div class="text-box">
                        <p>
                            <span class="text">附近医院</span>
                        </p>
                        <p>
                            <span class="hosName"></span>
                        </p>
                    </div>
                </a>
            </li>
             <li class="no-bottom-border">
                 <i class="mark"></i>
                 <span>当前位置:  上海</span>
                 <!--<i class="rest"></i>-->
             </li>
        </ul>
    </div>
    <div class="more">
        <a href="moreDoctor.html">更多医生<i></i></a>
    </div>
    <!-- 滑动 -->
    <div class="swiper-container">
        <div class="swiper-wrapper"></div>
        <div class="swiper-button-prev swiper-button-01"></div>
        <div class="swiper-button-next swiper-button-02"></div>
    </div>

</section>
<script src="/static/lib/swiper/swiper.min.js"></script>
<script>
    var mySwiper = ""
    $(function () {
        localStorage.removeItem('qysq')
        localStorage.removeItem('docId')
        var hospitalId = ''
        var info = localStorage.getItem('hosInfo')
        if(info){
            info = JSON.parse(info)
            hospitalId =info.hosId;
            getDoc(hospitalId);
            $('.hosName').text(info.hosName)
        }else {
            getHos()
        }
        $('#hosList').on('click',function () {
            localStorage.setItem('level','')
            location = "moreHospital.html"
        })
        $("body").on('click','.qy-btn',function () {
            var obj ={}
            obj.famId = $(this).attr('data-docId')
            localStorage.setItem('docId',obj.famId)
            localStorage.setItem('qysq', JSON.stringify(obj))
            location="qygrxx.html"
        });
        function getHos() {//获取医院信息
            $.QuickRemote.AjaxJson({
                funcName: "/api/gzd/qyfw/level"
                ,params: {level: '03',pageNumber:0,pageSize:10}
                ,callback: function(result) {
                    $('.hosName').text(result[0].hospitalName);
                    getDoc(result[0].hospitalId);
                    var obj = {
                        hosId : result[0].hospitalId,
                        hosName: result[0].hospitalName
                    }
                    localStorage.setItem('hosInfo',JSON.stringify(obj))
                }
            });
        }
        function getDoc(hospitalId) {
            $.QuickRemote.AjaxJson({//获取医生列表
                funcName: "/api/gzd/qyfw/doctor"
                ,params: {hospitalId: hospitalId}
                ,callback: function(result) {
                    $('.swiper-wrapper').html(' ')
                    var html = ""
                    if(result.length<8){
                        for(var i=0;i<result.length;i++){
                            var doc = result[i]
                            var img = (doc.avatar)?doc.avatar: '/static/images/doctor_image.jpg';
                            html+='<div class="swiper-slide">' +
                                '                <div class="doc-box">' +
                                '                    <div class="top-box">' +
                                '                         <div class="user-box">' +
                                '                             <div class="img-box">' +
                                '                                 <img src="'+img+'" alt="">' +
                                '                             </div>' +
                                '                             <h3 class="name">'+doc.name+'</h3>' +
                                '                             <div class="level-box">' +
                                '                                 <span class="level blue">'+doc.department+'</span>' +
                                '                                 <span class="level org">'+doc.duty+'</span>' +
                                '                             </div>' +
                                '                         </div>' +
                                '                        <div class="right-tool-box">' +
                                '                             <i></i><span>推荐</span>' +
                                '                        </div>' +
                                '                    </div>' +
                                '                    <div class="text-box">' +
                                '                        <span class="title">擅长治疗：</span>' +
                                '                        <div class="text">' +doc.intro+
                                '                        </div>' +
                                '                    </div>' +
                                '                    <a data-docId = "'+doc.id+'" class="qy-btn">立即签约</a>' +
                                '                </div>' +
                                '            </div>'
                        }
                    }else {
                        for(var i=0;i<8;i++){
                            var doc = result[i]
                            var img = (doc.avatar)?doc.avatar: '/static/images/doctor_image.jpg';
                            html+='<div class="swiper-slide">' +
                                '                <div class="doc-box">' +
                                '                    <div class="top-box">' +
                                '                         <div class="user-box">' +
                                '                             <div class="img-box">' +
                                '                                 <img src="'+img+'" alt="">' +
                                '                             </div>' +
                                '                             <h3 class="name">'+doc.name+'</h3>' +
                                '                             <div class="level-box">' +
                                '                                 <span class="level blue">'+doc.department+'</span>' +
                                '                                 <span class="level org">'+doc.duty+'</span>' +
                                '                             </div>' +
                                '                         </div>' +
                                '                        <div class="right-tool-box">' +
                                '                             <i></i><span>推荐</span>' +
                                '                        </div>' +
                                '                    </div>' +
                                '                    <div class="text-box">' +
                                '                        <span class="title">擅长治疗：</span>' +
                                '                        <div class="text">' +doc.intro+
                                '                        </div>' +
                                '                    </div>' +
                                '                    <a data-docId = "'+doc.id+'" class="qy-btn">立即签约</a>' +
                                '                </div>' +
                                '            </div>'
                        }
                    }
                    if(result.length == 0){
                        $('.swiper-container').hide()
                    }else{
                        $('.swiper-container').show();
                    }
                    $('.swiper-wrapper').append(html);
                    new Swiper('.swiper-container',{
                        prevButton:'.swiper-button-prev',
                        nextButton:'.swiper-button-next',
                    })
                }
            });
        }
    });
</script>
</body>
</html>